<template>
  <div class></div>
</template>
<script>
import axios from "@/utils/requestdp";

export default {
  name: "APIqueryDbGRLZB", // 供热量占比
  components: {},
  data() {
    return {};
  },
  watch: {},
  mounted() {
    this.watchEvent();
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (
        this.$store.state.daping.intervalArr["APIqueryDbGRLZB"] != undefined
      ) {
        clearInterval(
          this.$store.state.daping.intervalArr["APIqueryDbGRLZB"][0].interval
        );
      }
      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);
      this.$store.state.daping.intervalArr["APIqueryDbGRLZB"] = [
        { interval: interval }
      ];
    },
    loadData() {
      let queryJson = {"queries":[{"metric":"*","schema":"dwb"}],"table":"pipenet_m","search":"id=0"};

      axios.post("/open/queryDb", queryJson).then(res => {
        if (res.data.length) {
          this.$store.state.daping.queryDbGRLZB = res.data;
        }
      });
    }
  }
};
</script>
<style lang='scss' scoped>
</style>